package com.oplink.webems.common.utils;

import org.apache.shiro.SecurityUtils;

import com.oplink.webems.modules.sys.entity.User;
import com.oplink.webems.modules.sys.service.ShiroDbRealm.ShiroUser;

/**
 * 
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2014
 * </p>
 * <p>
 * Company: Oplink Communications
 * </p>
 * 
 * @author
 ** @serialData 2014-5-23 下午3:28:36
 * @version 1.0
 */

public class UserUtils {
	/**
	 * 取出Shiro中的当前用户Id.
	 */
	public static Long getCurrentUserId() {
		ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal();
		return user.id;
	}
	
	public static String getCurrentUserRoles(){
		ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal();
		return user.roles;
	}
}
